5a5c9c03478ed911e891178debf3480ecaa219f1,src/main/java/org/teachingkidsprogramming/recipes/completed/section08tdd/SimplePuzzle.java,SimplePuzzle,run,#,47
Before Change
int[] shuffled = shuffled(cells);
puzzle = new Puzzle(shuffled);
PuzzlePlayer player = new AStarPlayer(puzzle);
PuzzleState solution = player.solve();
PuzzleBoard board = new PuzzleBoard(puzzle, solution);
PuzzleWindow pw = new PuzzleWindow(board);
new Thread(new PuzzleAnimation(board)).start();
After Change
int[] shuffled = shuffled(cells);
puzzle = new Puzzle(shuffled);
PuzzlePlayer player = new AStarPlayer(puzzle);
solution = player.solve();
PuzzleBoard board = new PuzzleBoard(puzzle, solution);
PuzzleWindow pw = new PuzzleWindow(board);
new Thread(new PuzzleAnimation(board)).start();
pw.setWindowVisible(true);
}
catch (IllegalStateException e)
{
MessageBox.showMessage("This puzzle is not solvable, click ok to try again");
}
}
//until a solution to the puzzle is found
while (solution == null || !solution.isSolution());
}
}
//